﻿@model BooksListViewModel
@{
	ViewBag.Title = "Portal - Library";
	Layout = "~/Views/Shared/_MainLayoutPage.cshtml";
}
@section Styles
{
	<link type="text/css" rel="Stylesheet" media="screen" href="@Url.Content("~/Content/Css/library.min.css")" />
	<link type="text/css" rel="Stylesheet" media="screen" href="@Url.Content("~/Content/Css/tooltips.min.css")" />
	<link type="text/css" rel="Stylesheet" media="screen" href="@Url.Content("~/Content/Css/popupWindow.min.css")" />
	<link type="text/css" rel="Stylesheet" media="screen" href="@Url.Content("~/Content/Css/personPicker.min.css")"/>
	<!--[if lt IE 8]> <link type="text/css" rel="Stylesheet" media="screen" href="@Url.Content("~/Content/Css/ieFix.min.css")" /> <![endif]-->
}
@section Scripts
{
	<script type="text/javascript" src="@Url.Content("~/Content/Scripts/jquery.validate.min.js")"></script>
	<script type="text/javascript" src="@Url.Content("~/Content/Scripts/jquery.validate.unobtrusive.min.js")"></script>
	<script type="text/javascript" src="http://www.google.com/jsapi"></script>
	<script type="text/javascript" src="@Url.Content("~/Content/Scripts/tooltips.min.js")"></script>
	<script type="text/javascript" src="@Url.Content("~/Content/Scripts/library.min.js")"></script>
	<script type="text/javascript" src="@Url.Content("~/Content/Scripts/personPicker.min.js")"></script>
	<script type="text/javascript">google.load("books", "0");</script>
}

@section PopupSection
{
	@Html.Partial("PersonPicker")

	@Html.Partial("TagsPicker")

	@Html.Partial(@"~\Views\Tooltips\PersonInfoTooltip.cshtml")
	
	@Html.Partial(@"~\Views\Tooltips\GenericTooltip.cshtml")

	@Html.Partial("BookViewer")
	
	@Html.Partial("BookCoverForm")
	
	@Html.Partial("Alert")
	
	@Html.Partial("Confirmation")
}

@{
	Func<FilterType,string> filterUrl = filterName => Url.Action("List", new {page = 1, filterType = filterName, sortingField = Model.CurrentSortInfo.SortingField, sortingType = Model.CurrentSortInfo.SortingType});
	
	Func<SortField, MBOP.Core.Entities.Common.SortType, string> sortUrl = (sortField, sortType) => Url.Action("List", new {page = Model.CurrentPage, filterType = Model.CurrentFilter, sortingField = sortField, sortingType = sortType});
	
	Func<int, string> pageUrl = pageNum => Url.Action("List", new {page = pageNum, filterType = Model.CurrentFilter, sortingField = Model.CurrentSortInfo.SortingField, sortingType = Model.CurrentSortInfo.SortingType});
}

<div id="library" class="libraryMainContainer">
	
	<div class="libraryManagement">
		<div class="filtering">
			@Html.GenerateFilterLinks(Model.CurrentFilter,filterUrl)
		</div>
		<div class="sorting">@Html.GenerateSortLinks(Model.CurrentSortInfo,sortUrl)</div>

		@if (Model.PagesTotal > 1 && Model.PagesTotal >= Model.CurrentPage)
		{
			<div id="mainPagination" class="pagination">
				@Html.GeneratePageLinks(Model.CurrentPage, Model.PagesTotal, pageUrl)
			</div>
		}
	</div>
		
	<iframe name="ImageIDFrame" id="frImageID" class="hidden"></iframe>

	@Html.Partial("BookCreation", new BookViewModel())

	<div id="booksContainer">
		<div id="bookEditingMask" class="mask">&nbsp;</div>
		@if (Model.Books.Any())
		{
			foreach (var book in Model.Books)
			{
				@Html.Partial("Book", book);
			}
			
		}
		else if((bool)Session["isAdmin"])
		{
			<span class="icon addIcon mediumIcon">&nbsp;</span>
		}
	</div>
	<div class="libraryManagement">
		@if (Model.PagesTotal > 1 && Model.PagesTotal >= Model.CurrentPage)
		{
			<div class="pagination">@Html.GeneratePageLinks(Model.CurrentPage, Model.PagesTotal, pageUrl) </div>
		}
	</div>
</div>